﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/MasterPage/Site1.Master" AutoEventWireup="true" CodeBehind="CarrierTypeManager.aspx.cs" Inherits="TARS.AdminCP.Carrier" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadSkinManager ID="Metro" runat="server" Skin="Hay"/>
        <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="true" />
        <div>
             <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TARS_DeliveryConnectionString %>" SelectCommand="SELECT [ID], [ZoneName] FROM [t_BrachesZone] WHERE ([Active] = @Active)">
            <SelectParameters>
                <asp:Parameter DefaultValue="True" Name="Active" Type="Boolean" />
            </SelectParameters>
                 </asp:SqlDataSource>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

        </telerik:RadAjaxManager>
       <label for="NamesDDL">Select branches zone's name (if you need filter):</label>
         <div style="margin-top: 15px;margin-bottom:15px;">
        <telerik:RadComboBox ID="cboBranchesZone" Runat="server" 
            Skin="Metro" Width="250px" AutoPostBack="True" 
            DataTextField="ZoneName" DataValueField="ID" EnableLoadOnDemand="True" OnSelectedIndexChanged="cboBranchesZone_SelectedIndexChanged">
                 </telerik:RadComboBox>
             <asp:EntityDataSource ID="EntityDataSource3" runat="server">
             </asp:EntityDataSource>
             <asp:EntityDataSource ID="EntityDataSource2" runat="server" ConnectionString="name=TARS_DeliveryEntities" DefaultContainerName="TARSDelivery_EprojectEntities1" EnableFlattening="False" EntitySetName="t_BrachesZone" EntityTypeFilter="t_BrachesZone" Select="it.[ID], it.[ZoneName]">
             </asp:EntityDataSource>
          </div>
        <telerik:RadGrid EnableLinqExpressions="False" ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" 
            AutoGenerateEditColumn="True" CellSpacing="0" GridLines="None" AllowAutomaticInserts="false" 
            OnUpdateCommand="RadGrid1_UpdateCommand1" Skin="Hay" OnItemCommand="RadGrid1_ItemCommand1" 
            OnItemDataBound="RadGrid1_ItemDataBound" OnInsertCommand="RadGrid1_InsertCommand">
            <ClientSettings>
                <Selecting AllowRowSelect="True" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
            </ClientSettings>
<MasterTableView AutoGenerateColumns="False" allowfilteringbycolumn="True" TableLayout="Auto" 
    DataKeyNames="NewID" CommandItemDisplay="TopAndBottom"
    FilterExpression="([Active] = true)"
    >
 
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <EditItemTemplate>

    </EditItemTemplate>
    <Columns>
        <telerik:GridBoundColumn DataField="NewID" FilterControlAltText="Filter NewID column" HeaderText="NewID" SortExpression="NewID" UniqueName="NewID" Visible="False" EditFormHeaderTextFormat="">
            <ColumnValidationSettings>
                <ModelErrorMessage Text="" />
            </ColumnValidationSettings>
        </telerik:GridBoundColumn>
        <telerik:GridTemplateColumn DataField="ZoneName" FilterControlAltText="Filter ZoneName column"
             SortExpression="ZoneName" HeaderText="Branches Zone" UniqueName="ZoneName" AllowFiltering="false">
            <EditItemTemplate>
                <telerik:RadComboBox runat="server" ID="cboBranchesZone" EnableLoadOnDemand="True" 
                                        DataSourceID="SqlDataSource2" DataValueField="ID" DataTextField="ZoneName" AutoPostBack="true"
                                        HighlightTemplatedItems="true" Height="140px" Width="220px" DropDownWidth="420px"
                                        OnSelectedIndexChanged="OnSelectedIndexChangedHandler">
                    </telerik:RadComboBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="ZoneNameLabel" runat="server" Text='<%# Eval("ZoneName") %>'></asp:Label>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn AutoPostBackOnFilter="true" DataField="CarrierTypeName" FilterControlAltText="Filter CarrierTypeName column" HeaderText="Carrier Type's Name" SortExpression="CarrierTypeName" UniqueName="CarrierTypeName">
            <ColumnValidationSettings EnableModelErrorMessageValidation="True" EnableRequiredFieldValidation="True">
                <RequiredFieldValidator Display="Dynamic" ErrorMessage="*" ForeColor="Red"></RequiredFieldValidator>
                <ModelErrorMessage Font-Bold="True" ForeColor="Red" Text="" ToolTip="*" />
            </ColumnValidationSettings>
        </telerik:GridBoundColumn>
        <telerik:GridCheckBoxColumn DataField="Active" DataType="System.Boolean" 
            FilterControlAltText="Filter Active column" CurrentFilterFunction="EqualTo" 
            CurrentFilterValue="True" AutoPostBackOnFilter="true" HeaderText="Active" UniqueName="Active">
        </telerik:GridCheckBoxColumn>
        <telerik:GridDateTimeColumn DataField="CreatedTime" FilterControlAltText="Filter CreatedTime column" HeaderText="Created Time" EnableRangeFiltering="true" PickerType="DateTimePicker" UniqueName="CreatedTime" EditFormHeaderTextFormat="">
            <ColumnValidationSettings>
                <ModelErrorMessage Text="" />
            </ColumnValidationSettings>
        </telerik:GridDateTimeColumn>
    </Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>

    <EditItemStyle BackColor="LightGreen" />

<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
</MasterTableView>

<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>

<FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
            
        <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=TarsDataEntity" DefaultContainerName="TarsDataEntity" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="v_CarrierType">
        </asp:EntityDataSource>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server" EntityTypeName="">
        </asp:LinqDataSource>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"></asp:ObjectDataSource>
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TARS_DeliveryConnectionString %>" DeleteCommand="DELETE FROM [t_CarrierType] WHERE [ID] = @ID" InsertCommand="INSERT INTO [t_CarrierType] ([ID], [CarrierTypeName], [CreatedTime], [BranchesZoneID]) VALUES (@ID, @CarrierTypeName, @CreatedTime, @BranchesZoneID)" SelectCommand="SELECT * FROM [t_CarrierType] ORDER BY [CreatedTime] DESC" UpdateCommand="UPDATE [t_CarrierType] SET [CarrierTypeName] = @CarrierTypeName, [CreatedTime] = @CreatedTime, [BranchesZoneID] = @BranchesZoneID WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Object" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="ID" Type="String" />
                <asp:Parameter Name="CarrierTypeName" Type="String" />
                <asp:Parameter Name="CreatedTime" Type="DateTime" />
                <asp:Parameter Name="BranchesZoneID" Type="Object" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="CarrierTypeName" Type="String" />
                <asp:Parameter Name="CreatedTime" Type="DateTime" />
                <asp:Parameter Name="BranchesZoneID" Type="Object" />
                <asp:Parameter Name="ID" Type="Object" />
            </UpdateParameters>
        </asp:SqlDataSource>
            </telerik:RadAjaxPanel>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
            </div>
</asp:Content>
